/********************************************************************
  A SymbolBrowser plugin for JuffEd editor.

  Copyright: 2010 Aleksander Sokoloff <asokol@mail.ru>


  This program is free software; you can redistribute it and/or
  modify it under the terms of the GNU General Public License.
  version 2 as published by the Free Software Foundation.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*********************************************************************/


#ifndef SYMBOLBROWSER_VIEW_H
#define SYMBOLBROWSER_VIEW_H

#include <QWidget>
#include <QTreeView>
#include <QStandardItemModel>
#include <QList>

//class QTreeView;
//class QStandardItemModel;
class QStandardItem;
class DocumentParser;
class SymbolInfo;
class Item;


class SymbolBrowserView : public QWidget
{
Q_OBJECT
friend class DocumentParser;

public:
    explicit SymbolBrowserView(QWidget * parent = 0, Qt::WindowFlags f = 0);
    virtual ~SymbolBrowserView();

    QTreeView *treeView() { return mTreeView; }
    QStandardItemModel *treeModel() { return mModel; }

    bool settingsActivateOnSingleClick() const { return mSettingsActivateOnSingleClick;}
    void setSettingsActivateOnSingleClick(bool value);

    bool settingsDetail() const { return mSettingsDetail; }
    void setSettingsDetail(bool value);

    bool settingsExpand() const { return mSettingsExpand; }
    void setSettingsExpand(bool value);

    bool settingsSort() const { return mSettingsSort; }
    void setSettingsSort(bool value);

    void addParser(DocumentParser* parser);
    DocumentParser* getParserByDocument(QObject* document);

protected:
    DocumentParser *mActiveParser;
    QTreeView *mTreeView;
    QStandardItemModel *mModel;

private:
    bool mSettingsActivateOnSingleClick;
    bool mSettingsDetail;
    bool mSettingsSort;
    bool mSettingsExpand;
    QAction* createRelationAction(const SymbolInfo *symbol, QObject *parent);
    void skipToLine(int line);
    QList<DocumentParser *> mParsers;

private slots:
    void parserDestroyed(QObject * obj);
    void treeItemClicked(const QModelIndex &index);
    void treeItemActivated(const QModelIndex &index);
    void showContextMenu(QPoint pos);
    void sortByName(bool value);
    void relatedMenuTriggered();
};


#endif // SYMBOLBROWSER_VIEW_H



